package edu.tyut.game.logic

import androidx.lifecycle.liveData
import kotlinx.coroutines.Dispatchers
import kotlin.coroutines.CoroutineContext

object Repository {
    fun <T> fire(context: CoroutineContext = Dispatchers.IO, block: suspend () -> Result<T>) =
        liveData(context){
            val result = try {
                block()
            }catch (e: Exception){
                Result.failure(e)
            }
            emit(result)
        }
}